﻿using System;
using TI_BLE_HCI_ClientLib.GenericHCIEntities;
using TI_BLE_HCI_ClientLib.HCIBaseEntities;

namespace TI_BLE_HCI_ClientLib.HCIEvents
{
    public class HCIEvent_GAP_Device_Discovery_Done : HCIVendorSpecificEvent
    {
        private HCIVendorSpecificEventHostErrorCode _status;
        private Device[] _devices = new Device[0];

        public HCIVendorSpecificEventHostErrorCode Status
        {
            get { return _status; }
            set { _status = value; }
        }

        public Device[] Devices
        {
            get { return _devices; }
            set { _devices = value; }
        }

        public void addDevice(Device device)
        {
            Device[] devices = new Device[_devices.Length + 1];

            Array.Copy(_devices, 0, devices, 0, _devices.Length);
            devices[devices.Length - 1] = device;

            _devices = devices;
        }

        public HCIEvent_GAP_Device_Discovery_Done(HCIVendorSpecificEventHostErrorCode status)
        {
            _status = status;
        }

        public class Device
        {
            public enum EventTypeEnum
            {
                ConnectableUndirectedAdvertisement = 0,
                ConnectableDirectedAdvertisement = 1,
                DiscoverableUndirectedAdvertisement = 2,
                NonConnectableUndirectedAdvertisement = 3,
                ScanResponse = 4
            }

            public enum AddrTypeEnum
            {
                ADDRTYPE_PUBLIC = 0,
                ADDRTYPE_STATIC = 1,
                ADDRTYPE_PRIVATE_NONRESOLVE = 2,
                ADDRTYPE_PRIVATE_RESOLVE = 3
            }

            private EventTypeEnum _eventType;
            private AddrTypeEnum _addrType;
            private byte[] _addr;

            public EventTypeEnum EventType
            {
                get { return _eventType; }
                set { _eventType = value; }
            }

            public AddrTypeEnum AddrType
            {
                get { return _addrType; }
                set { _addrType = value; }
            }

            public byte[] Addr
            {
                get { return _addr; }
                set { _addr = value; }
            }

            public Device(
                EventTypeEnum eventType,
                AddrTypeEnum addrType,
                byte[] addr)
            {
                _eventType = eventType;
                _addrType = addrType;
                _addr = addr;
            }
        }
    }
}